'''
 * CaRComp Execution Environment
 * 
 * Copyright (C) 2011 Taylor L. Riche
 * 
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
'''

import unittest
import filecmp
from carcomp.framework import system, copier
from carcomp.tests.as_sys import as_sys
from carcomp.directory import cameras, localhost


class Test(unittest.TestCase):


    def setUp(self):
        cop = copier.Copier(s_file='{}ft/tests/as_sys/TEST_INPUT.txt'.format(localhost.local_directory.package_root),
                            d_hst=cameras.local_directory.address(cameras.CLIENT_NAME),
                            d_file='{}ft/tests/as_sys/'.format(cameras.local_directory.package_root))
        cop.copy()

    def tearDown(self):
        pass


    def test_as_sys(self):
        '''Files should be the same after exeuction'''
        as_sys.run_as_sys()
        cop = copier.Copier(s_file='{}ft/tests/as_sys/TEST_OUTPUT.txt'.format(cameras.local_directory.package_root),
                            s_hst=cameras.local_directory.address(cameras.CLIENT_NAME),
                            d_file='{}ft/tests/as_sys/'.format(localhost.local_directory.package_root))
        cop.copy()
        retval = filecmp.cmp('{}ft/tests/as_sys/TEST_INPUT.txt'.format(localhost.local_directory.package_root), 
                             '{}ft/tests/as_sys/TEST_OUTPUT.txt'.format(localhost.local_directory.package_root),
                             shallow=False)
        if not retval:
            raise system.FilesNotTheSameException 
            


if __name__ == "__main__":
    #import sys;sys.argv = ['', 'Test.testASSys']
    unittest.main()